import { getWarehouseIds } from "../../dao/auth";

const state = {
  WarehouseIds: [],
  WarehouseId: ''
}

const getters = {
  WarehouseIds: state => state.WarehouseIds,
  WarehouseId: state => state.WarehouseId
}

const mutations = {
  SET_WAREHOUSE_LINES(state, val) {
    state.WarehouseIds = val
  },
  SET_WAREHOUSE_LINE(state, val) {
    state.WarehouseId = val
  }
}

const actions = {
  loadWarehouseIds({ commit }) {
    return new Promise((resolve, reject) => {
      getWarehouseIds().then(res => {
        if (res) {
          console.log(res);
          commit('SET_WAREHOUSE_LINES', res)
          resolve('ok')
        }
      }).catch(e => {
        reject(e)
      })
    })
  }
}

export default {
  state,
  getters,
  mutations,
  actions
}